import pandas as pd
import matplotlib.pyplot as plt

# 从CSV文件中读取数据
df = pd.read_csv('top250-1.csv', sep='#', encoding='utf-8',
                 names=['num', 'title', 'year', 'area', 'genre', 'rating_num', 'comment_num', 'href'], header=0)

# 提取评分数据
rating_nums = df['rating_num'].astype(str)

# 绘制直方图
plt.hist(rating_nums, bins=11, edgecolor='yellow')


plt.xlabel('Rating')
plt.ylabel('Count')
plt.title('Distribution of Ratings')

# 显示图表

plt.show()